package AST;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import Lexer.Symbol;

public class ArithExpr {
	private List<Term> termList = new ArrayList<Term>();
	private List<Integer> opList = new ArrayList<Integer>();

	public ArithExpr(List<Term> termList, List<Integer> opList) {
		print();
		this.termList = termList;
		this.opList = opList;
	}

	public ArithExpr() {
		print();
	}

	public List<Term> getTermList() {
		return termList;
	}

	public void setTermList(List<Term> termList) {
		this.termList = termList;
	}

	public List<Integer> getOpList() {
		return opList;
	}

	public void setOpList(List<Integer> opList) {
		this.opList = opList;
	}

	public void addTermList(Term t) {

		this.termList.add(t);
	}

	public void addOpList(int op) {
		this.opList.add(op);
	}

	public void print() {
		System.out.println("ArithExpr");
	}

	public void genC(PW pw) {
		Iterator<Term> itTerm = termList.iterator();

		itTerm.next().genC(pw);
		for (int i : opList) {
			if (i == Symbol.PLUS)
				pw.print("+");
			if (i == Symbol.MINUS)
				pw.print("-");
			itTerm.next().genC(pw);
		}

	}

}
